package ma.ensias.healthme.admin;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

import ma.ensias.healthme.R;
import ma.ensias.healthme.dao.PersonneDao;
import ma.ensias.healthme.entities.Personne;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
public class ListComptesActivity extends Activity {
	
	ListView list;
    LazyAdapter adapter;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_list_comptes);
		

		ArrayList<Personne> personnes = new ArrayList<Personne>();

		//personnes=new PersonneDao().getAll();
		
		list=(ListView)findViewById(R.id.list);
		
		// Getting adapter by passing xml data ArrayList
        adapter=new LazyAdapter(this, personnes);        
        list.setAdapter(adapter);
        
       

        // Click event for single list row
        list.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				showDetail(((Personne)adapter.getItem(position)).getId());
			}
		});	 
	}
	
	
	private void showDetail (int id ){
		
		Intent i=new Intent(this,InfoCompteActivity.class);
		i.putExtra("personne",new PersonneDao().getPersonne(id));
		startActivity(i);
	}

	public void showDialogType(String inputMethodService) {
		// TODO Auto-generated method stub
		
	}
	
}